<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="setShortCuts" script:language="StarBasic">REM  *****  BASIC  *****


Function getShortCutManager()
REM Return the ShortCutManager for the current Office Module.
    Dim oModuleManager As Object, oModuleIdent
    Dim oModuleConfigManager As Object, oModuleConfigManagerSupplier As Object
    oModuleManager = createUnoService( &quot;com.sun.star.frame.ModuleManager&quot; )
    oModuleIdent = oModuleManager.identify( ThisComponent )
    oModuleConfigManagerSupplier = createUnoService( &quot;com.sun.star.ui.ModuleUIConfigurationManagerSupplier&quot; )
    oModuleConfigManager = oModuleConfigManagerSupplier.getUIConfigurationManager( oModuleIdent )
    getShortCutManager = oModuleConfigManager.getShortCutManager()
End Function


&apos;NUM0 = 256; NUM9 = 265;
&apos; A = 512; J = 521; Z = 537;  F1 = 768;  F12 = 779; DOWN = 1024;UP = 1025; LEFT = 1026;RIGHT = 1027; 
&apos;RETURN = 1280;ESCAPE = 1281;TAB = 1282; BACKSPACE = 1283; SPACE = 1284;
&apos; [ = 1315  ; ] = 1316
&apos; , = 1292; . = 1291; \; = 1317 &apos; = 1318; ~ = 1310;  


Sub AllOnikShortCutsHandler(action$)
&apos;Globalscope.BasicLibraries.LoadLibrary( &quot;MRILib&quot; )
&apos;BasicLibraries.LoadLibrary(&quot;XrayTool&quot;)
	Dim strCommandURL$, oKeyEvent, oKeyEventList
    Dim AllKeyEvents, oEventRec
	Dim EvDescr$, EvModif%, EvCode%, EvFunc$
	Dim Script$ : Script = &quot;vnd.sun.star.script:OOnik.oxt|py|onik.py$&quot;
	Dim LocParam$ : LocParam = &quot;?language=Python&amp;location=user:uno_packages&quot;
	&apos; перестало работать после установки LO 6.4 с сайта
	&apos; Array(&quot;CTRL + ALT + &apos;&quot;, 			6, 1318,					&quot;change_letter_at_end_e&quot;), _ 
	AllKeyEvents = Array(_
      Array(&quot;CTRL + ALT + A&quot;, 			6, com.sun.star.awt.Key.A, 	&quot;change_acute&quot;), _
	  Array(&quot;CTRL + ALT + E&quot;, 			6, com.sun.star.awt.Key.E,	 &quot;change_letter_at_end_e&quot;), _
	  Array(&quot;CTRL + ALT + T&quot;, 			6, com.sun.star.awt.Key.T, 	&quot;onik_titled&quot;), _
	  Array(&quot;CTRL + T&quot;, 						2, com.sun.star.awt.Key.T, 	&quot;onik&quot;), _
	  Array(&quot;CTRL + ALT + .&quot;, 			6, 1291,								&quot;change_acute&quot;), _
	  Array(&quot;CTRL + .&quot;, 						2, 1291,								&quot;add_oxia_for_unacuted_word&quot;), _
	  Array(&quot;CTRL + ALT + D&quot;, 			6, com.sun.star.awt.Key.D, 	&quot;digits_to_letters&quot;), _
	  Array(&quot;CTRL + ALT + O&quot;, 			6, com.sun.star.awt.Key.O, 	&quot;change_letter_at_end_o&quot;), _
	  Array(&quot;CTRL + ALT + SHIFT + O&quot;, 	7, com.sun.star.awt.Key.O, 	&quot;change_letter_at_start&quot;), _
	  Array(&quot;CTRL + ALT + I&quot;, 			6, com.sun.star.awt.Key.I, 	&quot;change_letter_i&quot;), _
	  Array(&quot;CTRL + ALT + Y&quot;, 			6, com.sun.star.awt.Key.Y, 	&quot;change_letter_e&quot;), _
	  Array(&quot;CTRL + ALT + SHIFT + T&quot;, 	7, com.sun.star.awt.Key.T, 	&quot;onik_titles_open&quot;), _
	  Array(&quot;CTRL + ALT + [&quot;, 			6, 1315,					&quot;move_acute_left&quot;), _
	  Array(&quot;CTRL + ALT + ]&quot;, 			6, 1316,					&quot;move_acute_right&quot;), _
	  Array(&quot;CTRL + ALT + Q&quot;, 			6, com.sun.star.awt.Key.Q, 	&quot;move_acute_end&quot;), _
  	  Array(&quot;CTRL + ALT + P&quot;, 			6, com.sun.star.awt.Key.P, 	&quot;pluralis&quot;), _
	  Array(&quot;CTRL + ALT + R&quot;, 			6, com.sun.star.awt.Key.R, 	&quot;onik_csl2ru&quot;), _
	  Array(&quot;CTRL + ALT + SHIFT + R&quot;, 			7, com.sun.star.awt.Key.R, 	&quot;onik_csl2ru_with_acutes&quot;), _
  	  )
	
	For i = LBound(AllKeyEvents) To UBound(AllKeyEvents)
		oEventRec = AllKeyEvents(i)
		EvDescr = oEventRec(0)
		EvModif = oEventRec(1)
		EvCode = oEventRec(2)
		EvFunc = oEventRec(3)
		strCommandURL = Script &amp; EvFunc &amp; LocParam
		
		oKeyEvent = CreateKeyEvent(EvModif, EvCode)
		
		If action = &quot;create&quot; Then
			SetCommandShortcut(oKeyEvent, strCommandURL)	
		ElseIf action = &quot;remove&quot; Then
			&apos; Проверка
		    oKeyEventList = getShortCutManager().getPreferredKeyEventsForCommandList(Array(strCommandURL))
    		If not IsEmpty(oKeyEventList(0)) Then
    			RemoveCommandShortcut(strCommandURL)
    		End If
		EndIf
	Next	
End Sub


Sub SetAllOnikShortCuts
	AllOnikShortCutsHandler(&quot;create&quot;)
End Sub


Sub RemoveAllOnikShortCuts
	AllOnikShortCutsHandler(&quot;remove&quot;)
End Sub



Sub SetCommandShortcut( oKeyEvent, strCommandURL as String )
    Dim oShortCutManager As Object
    oShortCutManager = getShortCutManager()
    oShortCutManager.setKeyEvent( oKeyEvent, strCommandURL )
    oShortCutManager.store()
End Sub

Sub RemoveCommandShortcut( strCommandURL as String )
REM Removes all the Keyboard Shortcut(s) associated with the specified Command.
REM &lt;strCommandURL&gt;: a Command that has one or more Keyboard Shortcuts to be removed from it.
    Dim oShortCutManager As Object
    oShortCutManager = getShortCutManager()
    oShortCutManager.removeCommandFromAllKeyEvents( strCommandURL ) 
    oShortCutManager.store()
End Sub

Function CreateKeyEvent( iModifiers as Integer, iKeyCode as Integer ) As com.sun.star.awt.KeyEvent
REM Construct and return a KeyEvent structure.
    Dim aKeyEvent As New com.sun.star.awt.KeyEvent
    aKeyEvent.Modifiers = iModifiers
    aKeyEvent.KeyCode = iKeyCode
    CreateKeyEvent = aKeyEvent
End Function
</script:module>